package com.cskaoyan.shopping.controller;

import com.cskaoyan.mall.commons.result.ResponseData;
import com.cskaoyan.mall.commons.result.ResponseUtil;
import com.cskaoyan.mall.constant.ShoppingRetCode;
import com.cskaoyan.shopping.dto.HomePageResponse;
import com.cskaoyan.shopping.service.IHomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description:
 * @Author llf
 * @Date 2022/6/17 22:53
 */
@RestController
public class HomePageController {
    @Autowired
    IHomeService iHomeService;

    @GetMapping("/shopping/homepage")
    public ResponseData HomePage() {
        HomePageResponse response = iHomeService.homepage();
        if (ShoppingRetCode.SUCCESS.getCode().equals(response.getCode())) {
            // 执行成功，直接返回前端需要的数据
            return new ResponseUtil().setData(response.getPanelContentItemDtos());
        }
        // 调用失败
        return new ResponseUtil().setErrorMsg(response.getMsg());
    }

}
